import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: 'Dashboard', icon: 'dashboard' }
    }]
  },

  {
    path: '/example',
    component: Layout,
    redirect: '/example/table',
    name: 'Example',
    meta: { title: 'Example', icon: 'example' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: 'Table', icon: 'table' }
      },
      {
        path: 'tree',
        name: 'Tree',
        component: () => import('@/views/tree/index'),
        meta: { title: 'Tree', icon: 'tree' }
      }
    ]
  },
  //===========陶凤鸣大棚管理路由============
  {
    path: '/tao',
    component: Layout,
    redirect: '/tao/baseconfig',
    name: 'tao',
    meta: { title: '陶凤鸣', icon: 'example' },
    children: [
      {
        path: 'baseconfig',
        name: 'BaseconfigList',
        component: () => import('@/views/baseconfig/List'),
        meta: { title: '图书管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baseconfig_form',
        name: 'BaseconfigList_Form',
        component: () => import('@/views/baseconfig/Form'),
        meta: { title: '图书表单', icon: 'table' }
      },
      {
        path: 'basefile',
        name: 'BasefileList',
        component: () => import('@/views/basefile/List'),
        meta: { title: '文件管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'basefile_form',
        name: 'BasefileList_Form',
        component: () => import('@/views/basefile/Form'),
        meta: { title: '文件表单', icon: 'table' }
      },
      {
        path: 'baselog',
        name: 'BaselogList',
        component: () => import('@/views/baselog/List'),
        meta: { title: '日志管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baselog_form',
        name: 'BaselogList_Form',
        component: () => import('@/views/baselog/Form'),
        meta: { title: '日志表单', icon: 'table' }
      },
      {
        path: 'baseprivilege',
        name: 'BaseprivilegeList',
        component: () => import('@/views/baseprivilege/List'),
        meta: { title: '权限管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baseprivilege_form',
        name: 'BaseprivilegeList_Form',
        component: () => import('@/views/baseprivilege/Form'),
        meta: { title: '日志表单', icon: 'table' }
      },
      {
        path: 'plant',
        name: 'BlantList',
        component: () => import('@/views/plant/List'),
        meta: { title: '植物识别', icon: 'table' }
      },
    ]
  },
  //===========曾秀玲大棚管理路由============
  {
    path: '/zen',
    component: Layout,
    redirect: '/zen/baserole',
    name: 'zen',
    meta: { title: '曾秀玲', icon: 'example' },
    children: [
      {
        path: 'baserole',
        name: 'BaseroleList',
        component: () => import('@/views/baserole/List'),
        meta: { title: '角色列表', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baserole_form',
        name: 'BaseroleList_Form',
        component: () => import('@/views/baserole/Form'),
        meta: { title: '角色表单', icon: 'table' }
      },
      {
        path: 'baseroleprivilege',
        name: 'BaseroleprivilegeList',
        component: () => import('@/views/baseroleprivilege/List'),
        meta: { title: '权限列表', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baseroleprivilege_form',
        name: 'BaseroleprivilegeList_Form',
        component: () => import('@/views/baseroleprivilege/Form'),
        meta: { title: '权限表单', icon: 'table' }
      },
      {
        path: 'baseuser',
        name: 'BaseuserList',
        component: () => import('@/views/baseuser/List'),
        meta: { title: '用户管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baseuser_form',
        name: 'Baseuser_Form',
        component: () => import('@/views/baseuser/Form'),
        meta: { title: '用户表单', icon: 'table' }
      },
      {
        path: 'baseuserrole',
        name: 'BaseuserroleList',
        component: () => import('@/views/baseuserrole/List'),
        meta: { title: '用户角色管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'baseuserrole_form',
        name: 'Baseuserrole_Form',
        component: () => import('@/views/baseuserrole/Form'),
        meta: { title: '角色表单', icon: 'table' }
      },
      {
        path: 'animal_recognition',
        name: 'animalRecognition',
        component: () => import('@/views/AnimalRecognition/index'),
        meta: { title: '人物识别' }
      }
    ]
  },
  
  //===========廖钰盈大棚管理路由============
  {
    path: '/liao',
    component: Layout,
    redirect: '/liao/message',
    name: 'liao',
    meta: { title: '廖钰盈', icon: 'example' },
    children: [
      {
        path: 'message',
        name: 'MessageList',
        component: () => import('@/views/message/List'),
        meta: { title: '信息管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'message_form',
        name: 'MessageList_Form',
        component: () => import('@/views/message/Form'),
        meta: { title: '信息表单', icon: 'table' }
      },
      {
        path: 'module',
        name: 'ModuleList',
        component: () => import('@/views/module/List'),
        meta: { title: '模块管理', icon: 'table' }
      },
      {
        hidden:true,// 有，但是不在菜单中显示
        path: 'module_form',
        name: 'ModuleList_Form',
        component: () => import('@/views/module/Form'),
        meta: { title: '模块表单', icon: 'table' }
      },
    ]
  },
    //==========datasetfile=============
    {
      path: '/zy',
      component: Layout,
      redirect: '/zy/datasetfile',
      name: 'zy',
      meta: { title: '张月', icon: 'example' },
      children: [
        {
          path: 'datasetfile',
          name: 'DatasetfileList',
          component: () => import('@/views/datasetfile/List'),
          meta: { title: '文件列表', icon: 'table' }
        },
        {
          hidden:true,  // 有，但是不在菜单中显示
          path: 'datasetfile_form',
          name: 'datasetfileList_Form',
          component: () => import('@/views/datasetfile/Form'),
          meta: { title: '大棚表单' }
        },
        

        //==========application=============
        {
          path: 'application',
          name: 'ApplicationList',
          component: () => import('@/views/application/List'),
          meta: { title: '程序列表', icon: 'table' }
        },
        {
          hidden:true,  // 有，但是不在菜单中显示
          path: 'application_form',
          name: 'applicationList_Form',
          component: () => import('@/views/application/Form'),
          meta: { title: '大棚表单' }
        },
        

        //==========greenhouse=============
        {
          path: 'greenhouse',
          name: 'GreenhouseList',
          component: () => import('@/views/greenhouse/List'),
          meta: { title: '绿色列表', icon: 'table' }
        },
        {
          hidden:true,  // 有，但是不在菜单中显示
          path: 'greenhouse_form',
          name: 'GreenhouseList_Form',
          component: () => import('@/views/greenhouse/Form'),
          meta: { title: '大棚表单' }
        },




        //==========interfaces=============
        {
          path: 'interfaces',
          name: 'InterfacesList',
          component: () => import('@/views/interfaces/List'),
          meta: { title: '接口列表', icon: 'table' }
        },
        {
          hidden:true,  // 有，但是不在菜单中显示
          path: 'interfaces_form',
          name: 'interfacesList_Form',
          component: () => import('@/views/interfaces/Form'),
          meta: { title: '大棚表单' }
        },

        {
          path: 'onerecognition',
          name: 'oneRecognition',
          component: () => import('@/views/onerecognition/index'),
          meta: { title: '植物识别',icon:'table' }
        },
      ]
    },
    {
      path: '/qhx',
      component: Layout,
      meta: { title: '邱华香', icon: 'example' },
      children: [
        {
          // 文章列表
          path: 'articlelist',
          component: () => import('@/views/article/List'),
          meta: { title: '文章列表', icon: 'table' }
        },
        {
          hidden: true,
          path: 'articleform',
          component: () => import('@/views/article/Form'),
          meta: { title: '文章表单', icon: 'tree' }
        },
        // 农业模块
        {
          path: 'categorylist',
          component: () => import('@/views/category/List'),
          meta: { title: '农业模块', icon: 'table' }
        },
        {
          hidden: true,
          path: 'categoryform',
          component: () => import('@/views/category/Form'),
          meta: { title: '添加表单', icon: 'tree' }
        },
        {
          path: 'AnimalRecognition',
          name: 'animalRecognition',
          component: () => import('@/views/AnimalRecognition/index'),
          meta: { title: '动物识别' ,icon: 'tree'}
        },
  
        // 评论
        {
          path: 'commentlist',
          component: () => import('@/views/comment/List'),
          meta: { title: '评论列表', icon: 'table' }
        },
        {
          hidden: true,
          path: 'commentform',
          component: () => import('@/views/comment/Form'),
          meta: { title: '描述表单', icon: 'tree' }
        },
        // 资料
        {
          path: 'datasetlist',
          component: () => import('@/views/dataset/List'),
          meta: { title: '资料列表', icon: 'table' }
        },
        {
          hidden: true,
          path: 'datasetform',
          component: () => import('@/views/dataset/Form'),
          meta: { title: '资料表单', icon: 'tree' }
        },
      ]
    },
      // 404 page must be placed at the end !!!
      { path: '*', redirect: '/404', hidden: true }
    ]
 


const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
